package ungDung;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JToolBar;

import clientMain.Main;

public class TabTruong extends JToolBar implements ActionListener{
	public JButton btnInforTruong;
	public JButton btnEditTruong;
		public TabTruong(){
			btnInforTruong = new JButton("Thong Tin", new ImageIcon("src/images/company.png"));
			this.add(btnInforTruong);
			btnInforTruong.addActionListener(this);
			
			btnEditTruong = new JButton("Sua Thong Tin",new ImageIcon("src/images/company.png"));
			this.add(btnEditTruong);
			btnEditTruong.addActionListener(this);
			
		}
		@Override
		public void actionPerformed(ActionEvent e) {
			if(e.getSource() == btnInforTruong){
				int index =Main.jTabbedPane.positionTab("Thong Tin"); 
				if(index==-1){
				
					Main.jTabbedPane.addTab(new View_Truong(),"Thong Tin");
					Main.jTabbedPane.setSelectedIndex(Main.jTabbedPane.getTabCount()-1);
				}else{
					Main.jTabbedPane.setSelectedIndex(index);
					return;
				}
			}
			if(e.getSource() ==btnEditTruong){
			
				int index = Main.jTabbedPane.positionTab("Sua");
				if(index==-1){
					Main.jTabbedPane.addTab(new Edit_Truong(), "Sua");
					Main.jTabbedPane.setSelectedIndex(Main.jTabbedPane.getTabCount()-1);
				}else{
					Main.jTabbedPane.setSelectedIndex(index);
					return;
				}
			}
			
		}
}
